package com.example.demo.controller;

import com.example.demo.entity.Student;
import com.example.demo.entity.Table;
import com.example.demo.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 专门用来返回表格数据的controller
 *
 */
//加上restController注解  相当于 默认在方法上面+了  responsebody 注解
@RestController
public class TableController {
    @Autowired
    StudentMapper studentMapper;

    @RequestMapping("getAllStudent")
    public Table<Student> getAllStudent(){
            Table<Student> tab = new Table<Student>();
        List<Student> students = studentMapper.selectList(null);
        tab.setData(students);
        System.out.println(students.toString());
        tab.setCount(students.size());
        return tab;
    }
}
